<?php
defined('SYSPATH') OR die('No direct access allowed.');
/**
 * material.php
 * @author ranuandra
 *
 * 14 Agu 2011 20:53:23
 *
 * 
 */

class Model_Material extends ORM
{
	
   protected $_has_many = array(
								'materialin' 	=> array('model' => 'materialin'),
   								'materialout' 	=> array('model' => 'materialout'),
   								'stock'			=> array('model' => 'stock')
							);
	protected $_has_one = array(
								'buffer'	=> array('model' => 'buffer')
							);
								
	private $_form = array('name' 		=> '',
							'code' 	=> '',
							);
							
	private $_field = array(
						'name', 'code',
					);

	public function rules()
	{
		return array(
			'name' 	   => array(
			 						array('min_length', array(':value', 0)),
			 ),
			'code' 	   => array(
			 						array('min_length', array(':value', 0)),
			 ),

		);
	}
	
	public function get_form()
	{
		return $this->_form;
	}
	
	public function get_field()
	{
		return $this->_field;
	}
	
	public function create_material($values)
	{
		return $this->values($values, $this->_field)->create();
	}
}